//
//  JCBillHeadView.m
//  JiFengDaRen
//
//  Created by shouhan on 2018/5/21.
//  Copyright © 2018年 陈永发. All rights reserved.
//

#import "JCBillHeadView.h"

@interface JCBillHeadView()

@property (nonatomic,strong) UIView * topView;

@property (nonatomic, strong) UIView * makeView;

@property (nonatomic, strong) UILabel * make_timeLabel;// 制定时间

@property (nonatomic, strong) UILabel * make_time;

@property (nonatomic, strong) UILabel * pens_num;// 笔数

@property (nonatomic, strong) UILabel * make_amountLabel;// 还款金额

@property (nonatomic, strong) UILabel * make_amount;// 还款金额

@property (nonatomic, strong) UILabel * poundage;//手续费


@end

@implementation JCBillHeadView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self initUI];
    }
    return self;
}

- (void)initUI
{
    self.backgroundColor = [UIColor colorWithHexString:@"#F5F9FC"];

    self.makeView = [UIView new];
    self.makeView.layer.masksToBounds = YES;
    self.makeView.layer.cornerRadius = 5;
    self.makeView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.makeView];
    
    self.make_timeLabel = [UILabel new];
    self.make_timeLabel.text = @"制定时间:";
    self.make_timeLabel.textColor = [UIColor colorWithHexString:@"#333333"];
    self.make_timeLabel.font = KSHSystemFont(14);
    [self.makeView addSubview:self.make_timeLabel];
    
    self.make_amountLabel = [UILabel new];
    self.make_amountLabel.text = @"还款金额:";
    self.make_amountLabel.textColor = [UIColor colorWithHexString:@"#333333"];
    self.make_amountLabel.font = KSHSystemFont(14);
    [self.makeView addSubview:self.make_amountLabel];
    
    self.make_time = [UILabel new];
    self.make_time.text = [Tool getCurrentDate];
    self.make_time.font = KSHSystemFont(14);
    self.make_time.textColor = [UIColor colorWithHexString:@"#333333"];
    [self.makeView addSubview:self.make_time];
    
    self.make_amount = [UILabel new];
    self.make_amount.textColor = [UIColor colorWithHexString:@"#333333"];
    self.make_amount.font = KSHSystemFont(14);
    [self.makeView addSubview:self.make_amount];

    self.pens_num = [UILabel new];
    self.pens_num.textColor = [UIColor colorWithHexString:@"#333333"];
    self.pens_num.font = KSHSystemFont(14);
    [self.makeView addSubview:self.pens_num];
    
    self.poundage = [UILabel new];
    self.poundage.text = @"手续费:";
    self.poundage.textColor = [UIColor colorWithHexString:@"#333333"];
    self.poundage.font = KSHSystemFont(14);
    [self.makeView addSubview:self.poundage];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    [self.makeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.bottom.right.equalTo(self);
        make.top.equalTo(self).offset(__I6Height(10));
    }];
    
    [@[self.make_timeLabel,self.make_amountLabel] mas_distributeViewsAlongAxis:MASAxisTypeVertical withFixedSpacing:__I6Height(14) leadSpacing:__I6Height(14) tailSpacing:__I6Height(14)];

    [@[self.make_timeLabel,self.make_amountLabel] mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.makeView).offset(__I6Width(15));
    }];
    
    [self.make_time mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.make_timeLabel.mas_right).offset(2);
        make.centerY.equalTo(self.make_timeLabel);
    }];
    
    [self.make_amount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.make_amountLabel.mas_right).offset(2);
        make.centerY.equalTo(self.make_amountLabel);
    }];
    
    [self.pens_num mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.makeView).offset(-__I6Width(15));
        make.centerY.equalTo(self.make_timeLabel);
    }];
    
    [self.poundage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.makeView).offset(-__I6Width(15));
        make.centerY.equalTo(self.make_amountLabel);
    }];
}

- (void)getStrAmount:(NSString *)strAmount andCount:(NSString *)strCount{
    self.make_amount.text = strAmount;
    self.pens_num.text = strCount;
}

- (void)getTotalFee:(NSString *)fee{
    self.poundage.text = [NSString stringWithFormat:@"手续费:%@元",fee];
}

@end
